home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / graphics.17 / graphics / graphics-0.17 / plot2fig / space.c < prev   
Encoding:
C/C++ Source or Header  |  1991-03-12  |  2.2 KB  |  52 lines

  1. /* libtek, a library of functions for tektronics 4010 compatible devices.
  2.    Copyright (C) 1989 Free Software Foundation, Inc.
  3.  
  4. libtek is distributed in the hope that it will be useful, but WITHOUT ANY
  5. WARRANTY.  No author or distributor accepts responsibility to anyone for the
  6. consequences of using it or for whether it serves any particular purpose or
  7. works at all, unless he says so in writing.  Refer to the GNU General Public
  8. License for full details.
  9.  
  10. Everyone is granted permission to copy, modify and redistribute libtek, but
  11. only under the conditions described in the GNU General Public License.  A copy
  12. of this license is supposed to have been given to you along with libtek so
  13. you can know your rights and responsibilities.  It should be in a file named
  14. COPYING.  Among other things, the copyright notice and this notice must be
  15. preserved on all copies.  */
  16.  
  17. /* This file is the space routine, which is a standard part of the plot
  18.    library.  It sets the lower left and upper right corners of the page.  The
  19.    plot will be scaled so that these coners fit the largest renderable area on
  20.    the page.  */
  21.  
  22. #include "sys-defines.h"
  23. #include "libplot.h"
  24. #include "extern.h"
  25.  
  26. double x_input_min = 0.;    /* minimum input x coordinate */
  27. double y_input_min = 0.;    /* minimum input y coordinate */
  28. /* Latex has troubles with plots larger than 6 inches (480). */
  29. /* The range (60,660) to (540,180) centers the plot in the fig window. */
  30. double x_output_min = 60.;   /* minimum output x coordinate */
  31. double y_output_min = 660.;   /* minimum output y coordinate */
  32. double x_output_max = 540.; /* maximum output x coordinate */
  33. double y_output_max = 180.; /* maximum output y coordinate */
  34. double scaleup = 1.;        /* maximum input to output scaleing of x and y */
  35. double x_scale = 1.;        /* input to output scaleing for x */
  36. double y_scale = 1.;        /* input to output scaleing for y */
  37.  
  38. int
  39. space (x0, y0, x1, y1)
  40.      int x0, y0, x1, y1;
  41. {
  42.   x_input_min = x0;
  43.   y_input_min = y0;
  44.   x_scale = (x1 - x0)/(x_output_max - x_output_min);
  45.   y_scale = (y1 - y0)/(y_output_max - y_output_min);
  46.   if (fabs(x_scale) > fabs(y_scale))
  47.     scaleup = fabs (x_scale);
  48.   else
  49.     scaleup = fabs (y_scale);
  50.   return 0;
  51. }
  52.